package com.lili.operate.service.serviceImpl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lili.model.operate.CustomWords;
import com.lili.model.operate.FeedBack;
import com.lili.operate.mapper.CustomWordsMapper;
import com.lili.operate.service.CustomWordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class CustomWordsServiceImpl implements CustomWordsService {
    @Autowired
    CustomWordsMapper customWordsMapper;

    /**
     * 更新分词名称
     * @param name
     * @param id
     * @return
     */
    @Override
    public int updateCustomWords(String name, long id) {
        return customWordsMapper.updateCustomWords(name,id);
    }

    /**
     * 删除分词
     * @param id
     * @return
     */
    @Override
    public int deleteCustomWords(long id) {
        return customWordsMapper.deleteCustomWords(id);
    }

    /**
     * 查询所有的分词
     * @param map
     * @return
     */
    @Override
    public Page<CustomWords> queryCustomWords(Map map) {
        int current = 1;
        int size = 2;
        if(map.get("current")!=null)
            current = Integer.parseInt(map.get("current").toString());
        if(map.get("size")!=null)
            current = Integer.parseInt(map.get("size").toString());
        Page<CustomWords> page = new Page<>(current,size);
        customWordsMapper.selectPage(page,null);
        return page;
    }

    /**
     * 新增分词
     * @param customWords
     * @return
     */
    @Override
    public int saveCustomWords(CustomWords customWords) {
        return customWordsMapper.insert(customWords);
    }
}
